/**
 * Created by admin on 2017/4/5.
 */

$(function () {
    var height=window.innerHeight;
    $('.register').css('height',height);
    var GetQueryString = function (key) {
        // key为url变量名称
        var urlGets = location.search.substr(1);
        if (urlGets.length > 0) {
            start = urlGets.indexOf(key + '=');
            if (start != -1) {
                start = start + key.length + 1;
                end = urlGets.indexOf('&', start);
                if (end == -1) {
                    end = urlGets.length
                }
                return decodeURIComponent(urlGets.substring(start, end));
            }
        }
        return "";
    };
    $('#down').click(function () {
        var val = $('#phoneNum').val();
        var reg = /^1[34578]\d{9}$/;
        var a = reg.test(val);
        if (a) {
            var code = GetQueryString("abc");
            $.ajax({
                type: 'get',
               url: 'http://dkx.yytaomeng.com/platform/list/addlist',
                //url: 'http://192.168.1.142:81/platform/list/addlist',
                contentType: 'application/json; charset=utf-8',
                dataType: 'jsonp',
                data: {
                    'phone': val,
                    'code': code
                },
                jsonp: 'callback',
                jsonpCallback: 'successCallback',
                success: function (data) {
                    console.log(data);
                    if(data.starts==0){
                        alert(data.msg);
                    }else{
                        if(data.starts==3){
                            alert(data.msg);
                            window.location.href="http://a.app.qq.com/o/simple.jsp?pkgname=com.znsb.daikuanxia";
                        }
                        window.location.href="http://a.app.qq.com/o/simple.jsp?pkgname=com.znsb.daikuanxia";
                    }
                },
                error: function (e) {
                    console.log('出错了');
                    console.log(e);
                }
            });

        } else {
            alert('手机号码输入有误！');
        }
    });
});
